/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_Studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "视口元素.h"



static S_线逐顶点有色线段材质* g_网格线材质 = nullptr;



void f_初始化3D视口基准网格线(S_设备环境& ctx) {
	f_node_初始化单虚拟体网格(ctx);
	S_框架::g_基准网格线 = f_ob_创建网格物体(ctx);
	S_框架::g_基准网格线->m_Name = L"场景视口网格";

	S_Mesh* 基线 = f_surface_创建网格对象(nullptr, ctx, E_网格数据枚举::e_Mesh_VULKAN);
	S_Mesh* 主线 = f_surface_创建网格对象(nullptr, ctx, E_网格数据枚举::e_Mesh_VULKAN);
	S_Mesh* 辅线 = f_surface_创建网格对象(nullptr, ctx, E_网格数据枚举::e_Mesh_VULKAN);
	f_ob_set数据槽数量(S_框架::g_基准网格线, 3);

	f_ob_set数据(S_框架::g_基准网格线, 基线, 0);
	f_ob_set数据(S_框架::g_基准网格线, 主线, 1);
	f_ob_set数据(S_框架::g_基准网格线, 辅线, 2);

	g_网格线材质 = new S_线逐顶点有色线段材质(ctx, true, E_绘制方式::e_画线段);
	f_ob_set材质(S_框架::g_基准网格线, g_网格线材质, 0);
	f_ob_set材质(S_框架::g_基准网格线, g_网格线材质, 1);
	f_ob_set材质(S_框架::g_基准网格线, g_网格线材质, 2);

	f_mesh_gen间接绘制网格属性(基线, 1);
	f_mesh_gen间接绘制网格属性(主线, 1);
	f_mesh_gen间接绘制网格属性(辅线, 1);
	S_MeshDrawProp Prop{};
	f_mesh_set绘制属性(基线, Prop);
	f_mesh_set绘制属性(主线, Prop);
	f_mesh_set绘制属性(辅线, Prop);

	auto 网格属性 = MeshProp_Init();
	网格属性.m_DepthScale = 1;
	f_mesh_set间接绘制网格属性(基线, 网格属性);
	f_mesh_set间接绘制网格属性(主线, 网格属性);
	f_mesh_set间接绘制网格属性(辅线, 网格属性);
	


	int32 num = 60;
	float32 长度 = 600;

	std::vector<S_VC> 顶点;
	顶点.reserve(4);
	顶点.push_back({ { -长度, 0.0f, 0.0f }, f_PackData4X8({ 255,100,100,200 }) });
	顶点.push_back({ { 长度, 0.0f, 0.0f }, f_PackData4X8({ 255,100,100,200 }) });
	顶点.push_back({ { 0.0f, 0.0f, -长度 }, f_PackData4X8({ 100,100,255,200 }) });
	顶点.push_back({ { 0.0f, 0.0f, 长度 }, f_PackData4X8({ 100,100,255,200 }) });
	f_surface_fill顶点数据(基线, 顶点);
	基线->m_线宽 = 1.5;


	顶点.clear();
	顶点.reserve(num * 4 * 2);
	for (uint32 i = 1; i < num; ++i) {
		vec3 vx = {};

		vx.x = 长度;
		vx.z = 10.0f * i;
		顶点.push_back({ vx, f_PackData4X8(S_节点UI主题::uic_主线辅线) });
		vx.x = -长度;
		顶点.push_back({ vx, f_PackData4X8(S_节点UI主题::uic_主线辅线) });

		vx.x = 长度;
		vx.z = -10.0f * float32(i);
		顶点.push_back({ vx, f_PackData4X8(S_节点UI主题::uic_主线辅线) });
		vx.x = -长度;
		顶点.push_back({ vx, f_PackData4X8(S_节点UI主题::uic_主线辅线) });



		vx.x = 10.0f * i;
		vx.z = 长度;
		顶点.push_back({ vx, f_PackData4X8(S_节点UI主题::uic_主线辅线) });
		vx.z = -长度;
		顶点.push_back({ vx, f_PackData4X8(S_节点UI主题::uic_主线辅线) });

		vx.x = -10.0f * i;
		vx.z = 长度;
		顶点.push_back({ vx, f_PackData4X8(S_节点UI主题::uic_主线辅线) });
		vx.z = -长度;
		顶点.push_back({ vx, f_PackData4X8(S_节点UI主题::uic_主线辅线) });
	}
	
	f_surface_fill顶点数据(主线, 顶点);
	主线->m_线宽 = 1.5;

	
	num *= 10;
	顶点.clear();
	顶点.reserve(num * 4 * 2);
	for (uint32 i = 1; i < num; ++i) {
		vec3 vx = {};

		vx.x = 长度;
		vx.z = i;
		顶点.push_back({ vx, f_PackData4X8(S_节点UI主题::uic_网格辅线) });
		vx.x = -长度;
		顶点.push_back({ vx, f_PackData4X8(S_节点UI主题::uic_网格辅线) });

		vx.x = 长度;
		vx.z = -float32(i);
		顶点.push_back({ vx, f_PackData4X8(S_节点UI主题::uic_网格辅线) });
		vx.x = -长度;
		顶点.push_back({ vx, f_PackData4X8(S_节点UI主题::uic_网格辅线) });



		vx.x = i;
		vx.z = 长度;
		顶点.push_back({ vx, f_PackData4X8(S_节点UI主题::uic_网格辅线) });
		vx.z = -长度;
		顶点.push_back({ vx, f_PackData4X8(S_节点UI主题::uic_网格辅线) });

		vx.x = -float32(i);
		vx.z = 长度;
		顶点.push_back({ vx, f_PackData4X8(S_节点UI主题::uic_网格辅线) });
		vx.z = -长度;
		顶点.push_back({ vx, f_PackData4X8(S_节点UI主题::uic_网格辅线) });
	}
	f_surface_fill顶点数据(辅线, 顶点);

	

	S_节点数据::m_包围盒物体 = f_node_创建包围盒虚拟体(ctx);
	S_物体::g_包围盒物体 = S_节点数据::m_包围盒物体;


	S_框架::g_Scene->f_add物体(S_框架::g_基准网格线);
	//f_scene_添加物体列表(S_框架::g_Scene, S_节点数据::m_包围盒物体);
}

void f_初始化物体可视包围盒(S_设备环境& ctx) {

}










//static S_物体* G手柄 = nullptr;
static S_Mesh* g手柄线 = nullptr;
static S_Mesh* g手柄面 = nullptr;
static S_物体* G外接圆线 = nullptr;

void f_初始化变换手柄(S_设备环境& ctx) {
	//S_框架::g_变换手柄_准备替换 = f_ob_创建网格物体(ctx);
	//f_ob_set数据槽数量(S_框架::g_变换手柄_准备替换, DEF_视口手柄元素总数量);

	if (!S_框架::g_手柄线材质) {
		S_框架::g_手柄线材质 = new S_线逐顶点有色线段材质(ctx, true, E_绘制方式::e_画线段);
		//f_material_add线属性(S_框架::g_手柄线材质, 12);
	}
	
	if (!S_框架::g_手柄面材质) {
		S_框架::g_手柄面材质 = new S_线逐顶点有色线段材质(ctx, true, E_绘制方式::e_三角形, E_填充模式::e_填充面);
		//f_material_add线属性(S_框架::g_手柄面材质, 12);
	}

	
	S_框架::g_变换手柄 = f_ob_创建物体(ctx, E_物体类型::t_网格);
	S_框架::g_变换手柄->m_渲染 = false;
	S_框架::g_变换手柄->m_Name = L"变换手柄";
	S_框架::g_Scene->f_add物体(S_框架::g_变换手柄);
	f_ob_set数据槽数量(S_框架::g_变换手柄, 2);
	S_框架::g_变换手柄->f_set位置({1,1,1});
	

	g手柄线 = f_surface_创建网格对象(nullptr, ctx, E_网格数据枚举::e_Mesh_VULKAN);
	g手柄面 = f_surface_创建实例(g手柄线, false);
	g手柄线->m_线宽 = 3.5;
	
	f_ob_set数据(S_框架::g_变换手柄, g手柄线, 0);
	f_ob_set数据(S_框架::g_变换手柄, g手柄面, 1);

	f_ob_set材质(S_框架::g_变换手柄, S_框架::g_手柄线材质, 0);
	f_ob_set材质(S_框架::g_变换手柄, S_框架::g_手柄面材质, 1);
	


	
	

	
	G外接圆线 = f_ob_添加实例(S_框架::g_变换手柄, 0); G外接圆线->m_ID = 0;   //0

	auto* 方向X线 = f_ob_添加实例(S_框架::g_变换手柄, 0); 方向X线->m_ID = 1;     //1
	auto* 方向Y线 = f_ob_添加实例(S_框架::g_变换手柄, 0); 方向Y线->m_ID = 2;     //2
	auto* 方向Z线 = f_ob_添加实例(S_框架::g_变换手柄, 0); 方向Z线->m_ID = 3;     //3

	auto* 旋转X线 = f_ob_添加实例(S_框架::g_变换手柄, 0); 旋转X线->m_ID = 4;     //4
	auto* 旋转Y线 = f_ob_添加实例(S_框架::g_变换手柄, 0); 旋转Y线->m_ID = 5;     //5
	auto* 旋转Z线 = f_ob_添加实例(S_框架::g_变换手柄, 0); 旋转Z线->m_ID = 6;     //6

	auto* 轴向X线 = f_ob_添加实例(S_框架::g_变换手柄, 0); 轴向X线->m_ID = 7;     //7
	auto* 轴向Y线 = f_ob_添加实例(S_框架::g_变换手柄, 0); 轴向Y线->m_ID = 8;     //8
	auto* 轴向Z线 = f_ob_添加实例(S_框架::g_变换手柄, 0); 轴向Z线->m_ID = 9;     //9

	

	auto* 移动箭头X = f_ob_添加实例(S_框架::g_变换手柄, 0); 移动箭头X->m_ID = 1; //11
	auto* 移动箭头Y = f_ob_添加实例(S_框架::g_变换手柄, 0); 移动箭头Y->m_ID = 2; //12
	auto* 移动箭头Z = f_ob_添加实例(S_框架::g_变换手柄, 0); 移动箭头Z->m_ID = 3; //13

	auto* 缩放箭头X = f_ob_添加实例(S_框架::g_变换手柄, 0); 缩放箭头X->m_ID = 4; //14
	auto* 缩放箭头Y = f_ob_添加实例(S_框架::g_变换手柄, 0); 缩放箭头Y->m_ID = 5; //15
	auto* 缩放箭头Z = f_ob_添加实例(S_框架::g_变换手柄, 0); 缩放箭头Z->m_ID = 6; //16

	
	auto* 中心点 = f_ob_添加实例(S_框架::g_变换手柄, 0); 中心点->m_ID = 0;       //10
	auto* 旋转角度示意面 = f_ob_添加实例(S_框架::g_变换手柄, 0); 旋转角度示意面->m_ID = 7; 
	
	S_框架::g_变换手柄方向线.push_back(方向X线);
	S_框架::g_变换手柄方向线.push_back(方向Y线);
	S_框架::g_变换手柄方向线.push_back(方向Z线);

	S_框架::g_变换手柄圆圈线.push_back(旋转X线);
	S_框架::g_变换手柄圆圈线.push_back(旋转Y线);
	S_框架::g_变换手柄圆圈线.push_back(旋转Z线);
	
	S_框架::g_变换手柄轴向线.push_back(轴向X线);
	S_框架::g_变换手柄轴向线.push_back(轴向Y线);
	S_框架::g_变换手柄轴向线.push_back(轴向Z线);

	S_框架::g_变换手柄移动箭头.push_back(移动箭头X);
	S_框架::g_变换手柄移动箭头.push_back(移动箭头Y);
	S_框架::g_变换手柄移动箭头.push_back(移动箭头Z);

	S_框架::g_变换手柄缩放端点.push_back(缩放箭头X);
	S_框架::g_变换手柄缩放端点.push_back(缩放箭头Y);
	S_框架::g_变换手柄缩放端点.push_back(缩放箭头Z);
	
	

	

	uint32 offset = 0;
	std::vector<S_VC> 顶点;

	S_RGBA8UI R = S_RGBA8UI{220, 70, 70, 242};
	S_RGBA8UI G = S_RGBA8UI{70 ,220, 70, 242};
	S_RGBA8UI B = S_RGBA8UI{70, 70, 220, 242};

	offset = 0;
	顶点.clear();
	std::vector<uint32> 索引;
	uint32 索引偏移 = 0;

	
	uvec2 立方体顶点数量 = f_graph_圆(顶点, 索引, 1.0, {0,0,0}, S_RGBA8UI{180,180,180,200});
	G外接圆线->m_PickIndirect = {立方体顶点数量.x, 1, offset, 0};
	offset += 立方体顶点数量.x;
	索引偏移 += 立方体顶点数量.y;


	
	顶点.push_back({ { 0.0f, 0.0f, 0.0f }, f_PackData4X8(R) });
	顶点.push_back({ { 1.0f, 0.0f, 0.0f }, f_PackData4X8(R) });
	索引.push_back(0); 索引.push_back(1);
	方向X线->m_PickIndirect = {2, 1, offset, 0};
	offset += 2;


	
	顶点.push_back({ { 0.0f, 0.0f, 0.0f }, f_PackData4X8(G) });
	顶点.push_back({ { 0.0f, 1.0f, 0.0f }, f_PackData4X8(G) });
	索引.push_back(0); 索引.push_back(1);
	方向Y线->m_PickIndirect = {2, 1, offset, 0};
	offset += 2;


	
	顶点.push_back({ { 0.0f, 0.0f, 0.0f }, f_PackData4X8(B) });
	顶点.push_back({ { 0.0f, 0.0f, 1.0f }, f_PackData4X8(B) });
	索引.push_back(0); 索引.push_back(1);
	方向Z线->m_PickIndirect = {2, 1, offset, 0};
	offset += 2;
	索引偏移 += 6;


	{
		轴向X线->m_PickIndirect = {2, 0, offset, 0};
		顶点.push_back({{ -10000.0f, 0.0f, 0.0f }, f_PackData4X8(R)});
		顶点.push_back({ { 10000.0f, 0.0f, 0.0f }, f_PackData4X8(R)});
		offset += 2;

		轴向Y线->m_PickIndirect = {2, 0, offset, 0};
		顶点.push_back({ { 0.0f, -10000.0f, 0.0f }, f_PackData4X8(G) });
		顶点.push_back({ { 0.0f, 10000.0f, 0.0f }, f_PackData4X8(G) });
		offset += 2;

		轴向Z线->m_PickIndirect = {2, 0, offset, 0};
		顶点.push_back({ { 0.0f, 0.0f, -10000.0f }, f_PackData4X8(B) });
		顶点.push_back({ { 0.0f, 0.0f, 10000.0f }, f_PackData4X8(B) });
		offset += 2;
	}
	

	auto 
	顶点区间 = f_graph_圆(顶点, 索引, 1.0, {0,0,0}, R, E_轴向::e_X);
	旋转X线->m_PickIndirect = {顶点区间.x, 1, offset, 0};
	offset += 旋转X线->m_PickIndirect.vertexCount;
	顶点区间 = f_graph_圆(顶点, 索引, 1.0, {0,0,0}, G, E_轴向::e_Y);
	旋转Y线->m_PickIndirect = {顶点区间.x, 1, offset, 0};
	offset += 旋转Y线->m_PickIndirect.vertexCount;
	顶点区间 = f_graph_圆(顶点, 索引, 1.0, {0,0,0}, B, E_轴向::e_Z);
	旋转Z线->m_PickIndirect = {顶点区间.x, 1, offset, 0};
	offset += 旋转Z线->m_PickIndirect.vertexCount;
	



	立方体顶点数量 = f_graph_立方体(顶点, 索引, {0.05, 0.05, 0.05}, {0,0,0}, S_RGBA8UI{80,80,80,255});
	中心点->m_PickIndirect = {立方体顶点数量.x, 1, offset, 0};
	offset += 立方体顶点数量.x;


	{
		顶点区间 = f_graph_锥形(顶点, 索引, {0.08f,0.35,6}, {}, R, E_轴向::e_X, true);
		移动箭头X->m_PickIndirect = {顶点区间.x, 1, offset, 0};
		offset += 移动箭头X->m_PickIndirect.vertexCount;

		顶点区间 = f_graph_锥形(顶点, 索引, {0.08f,0.35,6}, {}, G, E_轴向::e_Y, true);
		移动箭头Y->m_PickIndirect = {顶点区间.x, 1, offset, 0};
		offset += 移动箭头Y->m_PickIndirect.vertexCount;

		顶点区间 = f_graph_锥形(顶点, 索引, {0.08f,0.35,6}, {}, B, E_轴向::e_Z, true);
		移动箭头Z->m_PickIndirect = {顶点区间.x, 1, offset, 0};
		offset += 移动箭头Z->m_PickIndirect.vertexCount;
	}
	


	
	vec3 size = {0.1, 0.1, 0.1};
	立方体顶点数量 = f_graph_立方体(顶点, 索引, size, {0,0,0}, R);
	//缩放箭头X->m_IndexeIndirect = {立方体顶点数量.y, 1, 0, offset, 0};
	缩放箭头X->m_PickIndirect = {立方体顶点数量.x, 1, offset, 0};
	offset += 立方体顶点数量.x;
	//索引偏移 += 立方体顶点数量.y;

	立方体顶点数量 = f_graph_立方体(顶点, 索引, size, {0,0,0}, G);
	//缩放箭头Y->m_IndexeIndirect = {立方体顶点数量.y, 1, 0, offset, 0};
	缩放箭头Y->m_PickIndirect = {立方体顶点数量.x, 1, offset, 0};
	offset += 立方体顶点数量.x;
	//索引偏移 += 立方体顶点数量.y;
	
	立方体顶点数量 = f_graph_立方体(顶点, 索引, size, {0,0,0}, B);
	//缩放箭头Z->m_IndexeIndirect = {立方体顶点数量.y, 1, 0, offset, 0};
	缩放箭头Z->m_PickIndirect = {立方体顶点数量.x, 1, offset, 0};
	offset += 立方体顶点数量.x;
	//索引偏移 += 立方体顶点数量.y;

	offset = f_surface_fill顶点数据(g手柄线, 顶点);

	
	G外接圆线->m_PickIndirect.firstVertex += offset;
	方向X线->m_PickIndirect.firstVertex += offset;
	方向Y线->m_PickIndirect.firstVertex += offset;
	方向Z线->m_PickIndirect.firstVertex += offset;
	轴向X线->m_PickIndirect.firstVertex += offset;
	轴向Y线->m_PickIndirect.firstVertex += offset;
	轴向Z线->m_PickIndirect.firstVertex += offset;
	旋转X线->m_PickIndirect.firstVertex += offset;
	旋转Y线->m_PickIndirect.firstVertex += offset;
	旋转Z线->m_PickIndirect.firstVertex += offset;
	中心点->m_PickIndirect.firstVertex += offset;
	移动箭头X->m_PickIndirect.firstVertex += offset;
	移动箭头Y->m_PickIndirect.firstVertex += offset;
	移动箭头Z->m_PickIndirect.firstVertex += offset;
	缩放箭头X->m_PickIndirect.firstVertex += offset;
	缩放箭头Y->m_PickIndirect.firstVertex += offset;
	缩放箭头Z->m_PickIndirect.firstVertex += offset;

	//G外接圆线->m_PickIndirect.firstInstance = S_框架::g_变换手柄->m_变换矩阵.m_Mem.m_偏移;
	//方向X线->m_PickIndirect.firstInstance = S_框架::g_变换手柄->m_变换矩阵.m_Mem.m_偏移;
	//方向Y线->m_PickIndirect.firstInstance = S_框架::g_变换手柄->m_变换矩阵.m_Mem.m_偏移;
	//方向Z线->m_PickIndirect.firstInstance = S_框架::g_变换手柄->m_变换矩阵.m_Mem.m_偏移;
	//轴向X线->m_PickIndirect.firstInstance = S_框架::g_变换手柄->m_变换矩阵.m_Mem.m_偏移;
	//轴向Y线->m_PickIndirect.firstInstance = S_框架::g_变换手柄->m_变换矩阵.m_Mem.m_偏移;
	//轴向Z线->m_PickIndirect.firstInstance = S_框架::g_变换手柄->m_变换矩阵.m_Mem.m_偏移;
	//旋转X线->m_PickIndirect.firstInstance = S_框架::g_变换手柄->m_变换矩阵.m_Mem.m_偏移;
	//旋转Y线->m_PickIndirect.firstInstance = S_框架::g_变换手柄->m_变换矩阵.m_Mem.m_偏移;
	//旋转Z线->m_PickIndirect.firstInstance = S_框架::g_变换手柄->m_变换矩阵.m_Mem.m_偏移;
	//中心点->m_PickIndirect.firstInstance = S_框架::g_变换手柄->m_变换矩阵.m_Mem.m_偏移;
	//移动箭头X->m_PickIndirect.firstInstance = S_框架::g_变换手柄->m_变换矩阵.m_Mem.m_偏移;
	//移动箭头Y->m_PickIndirect.firstInstance = S_框架::g_变换手柄->m_变换矩阵.m_Mem.m_偏移;
	//移动箭头Z->m_PickIndirect.firstInstance = S_框架::g_变换手柄->m_变换矩阵.m_Mem.m_偏移;
	//缩放箭头X->m_PickIndirect.firstInstance = S_框架::g_变换手柄->m_变换矩阵.m_Mem.m_偏移;
	//缩放箭头Y->m_PickIndirect.firstInstance = S_框架::g_变换手柄->m_变换矩阵.m_Mem.m_偏移;
	//缩放箭头Z->m_PickIndirect.firstInstance = S_框架::g_变换手柄->m_变换矩阵.m_Mem.m_偏移;

	f_surface_add间接绘制(g手柄线, G外接圆线->m_PickIndirect);
	f_surface_add间接绘制(g手柄线, 方向X线->m_PickIndirect);
	f_surface_add间接绘制(g手柄线, 方向Y线->m_PickIndirect);
	f_surface_add间接绘制(g手柄线, 方向Z线->m_PickIndirect);
	f_surface_add间接绘制(g手柄线, 轴向X线->m_PickIndirect);
	f_surface_add间接绘制(g手柄线, 轴向Y线->m_PickIndirect);
	f_surface_add间接绘制(g手柄线, 轴向Z线->m_PickIndirect);
	f_surface_add间接绘制(g手柄线, 旋转X线->m_PickIndirect);
	f_surface_add间接绘制(g手柄线, 旋转Y线->m_PickIndirect);
	f_surface_add间接绘制(g手柄线, 旋转Z线->m_PickIndirect);
	f_surface_add间接绘制(g手柄面, 中心点->m_PickIndirect);
	f_surface_add间接绘制(g手柄面, 移动箭头X->m_PickIndirect);
	f_surface_add间接绘制(g手柄面, 移动箭头Y->m_PickIndirect);
	f_surface_add间接绘制(g手柄面, 移动箭头Z->m_PickIndirect);
	f_surface_add间接绘制(g手柄面, 缩放箭头X->m_PickIndirect);
	f_surface_add间接绘制(g手柄面, 缩放箭头Y->m_PickIndirect);
	f_surface_add间接绘制(g手柄面, 缩放箭头Z->m_PickIndirect);



	S_MeshDrawProp 线Prop{};
	线Prop.MeshPropOffset = g手柄线->m_网格元素属性.m_Mem.m_偏移;
	f_mesh_set绘制属性(g手柄线, 线Prop);
	S_MeshDrawProp 面Prop{};
	面Prop.MeshPropOffset = g手柄面->m_网格元素属性.m_Mem.m_偏移;
	f_mesh_set绘制属性(g手柄面, 面Prop);




	S_MeshTranformProp 线属性 = MeshProp_Init();
	线属性.m_DottedLine = 1;
	线属性.m_Remote = 1;
	线属性.m_DepthScale = 1;

	线属性.m_TransformMode = DEF_MESH_LINE_TRANFORMTYPEMODEL_NONE;
	S_框架::G变换手柄方向线绘制属性 = 线属性;
	//f_material_set线属性(S_框架::g_手柄线材质, 轴向X线->m_ID, S_框架::G变换手柄方向线绘制属性);
	//f_material_set线属性(S_框架::g_手柄线材质, 轴向Y线->m_ID, S_框架::G变换手柄方向线绘制属性);
	//f_material_set线属性(S_框架::g_手柄线材质, 轴向Z线->m_ID, S_框架::G变换手柄方向线绘制属性);
	f_mesh_set间接绘制网格属性(g手柄线, S_框架::G变换手柄方向线绘制属性, 轴向X线->m_ID);
	f_mesh_set间接绘制网格属性(g手柄线, S_框架::G变换手柄方向线绘制属性, 轴向Y线->m_ID);
	f_mesh_set间接绘制网格属性(g手柄线, S_框架::G变换手柄方向线绘制属性, 轴向Z线->m_ID);


	线属性.m_DepthScale = 0.0001;
	S_框架::G变换手柄方向线绘制属性 = 线属性;
	//f_material_set线属性(S_框架::g_手柄线材质, 方向X线->m_ID, S_框架::G变换手柄方向线绘制属性);
	//f_material_set线属性(S_框架::g_手柄线材质, 方向Y线->m_ID, S_框架::G变换手柄方向线绘制属性);
	//f_material_set线属性(S_框架::g_手柄线材质, 方向Z线->m_ID, S_框架::G变换手柄方向线绘制属性);
	f_mesh_set间接绘制网格属性(g手柄线, S_框架::G变换手柄方向线绘制属性, 方向X线->m_ID);
	f_mesh_set间接绘制网格属性(g手柄线, S_框架::G变换手柄方向线绘制属性, 方向Y线->m_ID);
	f_mesh_set间接绘制网格属性(g手柄线, S_框架::G变换手柄方向线绘制属性, 方向Z线->m_ID);

	//f_material_set线属性(S_框架::g_手柄线材质, 旋转X线->m_ID, S_框架::G变换手柄方向线绘制属性);
	//f_material_set线属性(S_框架::g_手柄线材质, 旋转Y线->m_ID, S_框架::G变换手柄方向线绘制属性);
	//f_material_set线属性(S_框架::g_手柄线材质, 旋转Z线->m_ID, S_框架::G变换手柄方向线绘制属性);
	f_mesh_set间接绘制网格属性(g手柄线, S_框架::G变换手柄方向线绘制属性, 旋转X线->m_ID);
	f_mesh_set间接绘制网格属性(g手柄线, S_框架::G变换手柄方向线绘制属性, 旋转Y线->m_ID);
	f_mesh_set间接绘制网格属性(g手柄线, S_框架::G变换手柄方向线绘制属性, 旋转Z线->m_ID);

	
	线属性.m_TransformMode = DEF_MESH_LINE_TRANFORMTYPEMODEL_CAMERAGAZE;
	//线属性.m_TransformMode = DEF_MESH_LINE_TRANFORMTYPEMODEL_NONE;
	S_框架::G变换手柄外接圆绘制属性 = 线属性;
	//f_material_set线属性(S_框架::g_手柄线材质, G外接圆线->m_ID, 线属性);
	f_mesh_set间接绘制网格属性(g手柄线, 线属性, G外接圆线->m_ID);

	

	线属性.m_XMove = 1;
	线属性.m_TransformMode = DEF_MESH_LINE_TRANFORMTYPEMODEL_NONE;
	//f_material_set线属性(S_框架::g_手柄面材质, 中心点->m_ID, 线属性);
	f_mesh_set间接绘制网格属性(g手柄线, 线属性, 中心点->m_ID);


	S_框架::G变换手柄端箭头绘制属性[0] = 线属性;
	//f_material_set线属性(S_框架::g_手柄面材质, 缩放箭头X->m_ID, S_框架::G变换手柄端箭头绘制属性[0]);
	//f_material_set线属性(S_框架::g_手柄面材质, 移动箭头X->m_ID, S_框架::G变换手柄端箭头绘制属性[0]);
	f_mesh_set间接绘制网格属性(g手柄面, S_框架::G变换手柄端箭头绘制属性[0], 缩放箭头X->m_ID);
	f_mesh_set间接绘制网格属性(g手柄面, S_框架::G变换手柄端箭头绘制属性[0], 移动箭头X->m_ID);

	线属性.m_XMove = 0;
	线属性.m_YMove = 1;
	线属性.m_ZMove = 0;
	S_框架::G变换手柄端箭头绘制属性[1] = 线属性;
	//f_material_set线属性(S_框架::g_手柄面材质, 缩放箭头Y->m_ID, S_框架::G变换手柄端箭头绘制属性[1]);
	//f_material_set线属性(S_框架::g_手柄面材质, 移动箭头Y->m_ID, S_框架::G变换手柄端箭头绘制属性[1]);
	f_mesh_set间接绘制网格属性(g手柄面, S_框架::G变换手柄端箭头绘制属性[1], 缩放箭头Y->m_ID);
	f_mesh_set间接绘制网格属性(g手柄面, S_框架::G变换手柄端箭头绘制属性[1], 移动箭头Y->m_ID);

	线属性.m_XMove = 0;
	线属性.m_YMove = 0;
	线属性.m_ZMove = 1;
	S_框架::G变换手柄端箭头绘制属性[2] = 线属性;
	//f_material_set线属性(S_框架::g_手柄面材质, 缩放箭头Z->m_ID, S_框架::G变换手柄端箭头绘制属性[2]);
	//f_material_set线属性(S_框架::g_手柄面材质, 移动箭头Z->m_ID, S_框架::G变换手柄端箭头绘制属性[2]);
	f_mesh_set间接绘制网格属性(g手柄面, S_框架::G变换手柄端箭头绘制属性[2], 缩放箭头Z->m_ID);
	f_mesh_set间接绘制网格属性(g手柄面, S_框架::G变换手柄端箭头绘制属性[2], 移动箭头Z->m_ID);



	f_变换手柄_移动手柄显示(true);

}


void f_变换手柄_移动手柄显示(bool 打开) {
	
	auto* ob = f_ob_get子对象(S_框架::g_变换手柄, 0);
	ob->m_PickIndirect.instanceCount = 1;
	f_surface_set间接绘制区间(g手柄线, ob->m_PickIndirect, ob->m_ID);

	for (auto& ob : S_框架::g_变换手柄方向线) {
		ob->m_PickIndirect.instanceCount = 1;
		f_surface_set间接绘制区间(g手柄线, ob->m_PickIndirect, ob->m_ID);
	}

	for (auto& ob : S_框架::g_变换手柄移动箭头) {
		ob->m_PickIndirect.instanceCount = 1;
		f_surface_set间接绘制区间(g手柄面, ob->m_PickIndirect, ob->m_ID);
	}

	for (uint32 i = 0; i < 3; ++i) {
		ob = S_框架::g_变换手柄圆圈线[i];
		ob->m_PickIndirect.instanceCount = 0;
		f_surface_set间接绘制区间(g手柄线, ob->m_PickIndirect, ob->m_ID);

		ob = S_框架::g_变换手柄缩放端点[i];
		ob->m_PickIndirect.instanceCount = 0;
		f_surface_set间接绘制区间(g手柄面, ob->m_PickIndirect, ob->m_ID);
	}

	S_MeshTranformProp 线属性 = MeshProp_Init();
	线属性.m_Scale = 0.2;
	线属性.m_TransformMode = DEF_MESH_LINE_TRANFORMTYPEMODEL_CAMERAGAZE;
	//f_material_set线属性(S_框架::g_手柄线材质, G外接圆线->m_ID, 线属性);
	f_mesh_set间接绘制网格属性(g手柄线, 线属性, G外接圆线->m_ID);
}

void f_变换手柄_旋转手柄显示(bool 打开) {

	for (uint32 i = 0; i < 3; ++i) {
		auto* ob = S_框架::g_变换手柄圆圈线[i];
		ob->m_PickIndirect.instanceCount = 1;
		f_surface_set间接绘制区间(g手柄线, ob->m_PickIndirect, ob->m_ID);

		ob = S_框架::g_变换手柄方向线[i];
		ob->m_PickIndirect.instanceCount = 0;
		f_surface_set间接绘制区间(g手柄线, ob->m_PickIndirect, ob->m_ID);

		ob = S_框架::g_变换手柄移动箭头[i];
		ob->m_PickIndirect.instanceCount = 0;
		f_surface_set间接绘制区间(g手柄面, ob->m_PickIndirect, ob->m_ID);

		ob = S_框架::g_变换手柄缩放端点[i];
		ob->m_PickIndirect.instanceCount = 0;
		f_surface_set间接绘制区间(g手柄面, ob->m_PickIndirect, ob->m_ID);
	}

	G外接圆线->m_PickIndirect.instanceCount = 1;
	f_surface_set间接绘制区间(g手柄线, G外接圆线->m_PickIndirect, G外接圆线->m_ID);


	S_MeshTranformProp 线属性 = MeshProp_Init();
	线属性.m_Scale = 1.3;
	线属性.m_TransformMode = DEF_MESH_LINE_TRANFORMTYPEMODEL_CAMERAGAZE;
	//f_material_set线属性(S_框架::g_手柄线材质, G外接圆线->m_ID, 线属性);
	f_mesh_set间接绘制网格属性(g手柄线, 线属性, G外接圆线->m_ID);
}

void f_变换手柄_缩放手柄显示(bool 打开) {
	for (uint32 i = 0; i < 3; ++i) {
		auto* ob = S_框架::g_变换手柄方向线[i];
		ob->m_PickIndirect.instanceCount = 1;
		f_surface_set间接绘制区间(g手柄线, ob->m_PickIndirect, ob->m_ID);

		ob = S_框架::g_变换手柄缩放端点[i];
		ob->m_PickIndirect.instanceCount = 1;
		f_surface_set间接绘制区间(g手柄面, ob->m_PickIndirect, ob->m_ID);

		ob = S_框架::g_变换手柄圆圈线[i];
		ob->m_PickIndirect.instanceCount = 0;
		f_surface_set间接绘制区间(g手柄线, ob->m_PickIndirect, ob->m_ID);

		ob = S_框架::g_变换手柄方向线[i];
		ob->m_PickIndirect.instanceCount = 0;
		f_surface_set间接绘制区间(g手柄面, ob->m_PickIndirect, ob->m_ID);
	}

	G外接圆线->m_PickIndirect.instanceCount = 1;
	f_surface_set间接绘制区间(g手柄线, G外接圆线->m_PickIndirect, G外接圆线->m_ID);


	S_MeshTranformProp 线属性 = MeshProp_Init();
	线属性.m_Scale = 1.3;
	线属性.m_TransformMode = DEF_MESH_LINE_TRANFORMTYPEMODEL_CAMERAGAZE;
	//f_material_set线属性(S_框架::g_手柄线材质, G外接圆线->m_ID, 线属性);
	f_mesh_set间接绘制网格属性(g手柄线, 线属性, G外接圆线->m_ID);
}







